<template>
  <div class="goods-hot">
    <h3>{{title}}</h3>
    <div v-if="goodsList">
      <GoodsItem v-for="item in goodsList" :key="item.id" :goods="item"/>
    </div>
  </div>
</template>
<script>
import GoodsItem from "@/views/category/components/CategoryGoods.vue"
import { computed, ref } from 'vue';
import { findGoodsHot } from '@/api/goods';
import { useRoute } from 'vue-router';
export default {
  name: "GoodsHot",
  components: { GoodsItem },
  props:{
    type:{
        type:Number,
        default:1
    }
  },
  setup(props){
    const typeList = {1:'24小时热榜',2:'周榜',3:'总榜'}
    // 标题返回键值
    const title = computed(()=>{
        return typeList[props.type]
    })
    // 获取数据
    const goodsList = ref([])
    const route = useRoute()
    findGoodsHot({id:route.params.id,type:props.type}).then(data=>{
        // console.log(data.result,'123')
        goodsList.value = data.result
    })
    return {typeList, title, goodsList}
  }
};
</script>
<style lang="less" scoped>
.goods-hot {
  h3 {
    height: 70px;
    background: @helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }
  :v-deep(.goods-item) {
    background: #fff;
    width: 100%;
    margin-bottom: 10px;
    img {
      width: 200px;
      height: 200px;
    }
    p {
      margin: 0 10px;
    }
    &:hover {
      transform: none;
      box-shadow: none;
    }
  }
}
:deep(.goods-item){
    width: 280px;
    background-color: #fff;
    margin-top:10px;
}
</style>
